package com.neuedu.web.controller;

import com.alibaba.fastjson2.JSONObject;
import com.neuedu.web.common.BaseMethodController;
import com.neuedu.web.common.PageInfo;
import com.neuedu.web.po.UmsUser;
import com.neuedu.web.po.User;
import com.neuedu.web.service.UserService;
import com.neuedu.web.utils.JSONUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 金山
 * 项目：javaweb
 * site: https://blog.fulfill.com.cn
 * <p>
 * http://127.0.0.1:8080/web/user_list
 * <p>
 * <p>
 *
 *
 *
 *     http://localhost:8080/web/user/list
 *     http://localhost:8080/web/user/save
 *     http://localhost:8080/web/user/insert
 *     http://localhost:8080/web/user/delete
 *
 *
 * 描述
 * @data 2024/11/149:51
 */
@WebServlet(urlPatterns = "/user/*")
public class UserController extends BaseMethodController {

    private UserService userService = new UserService();

    /**
     * http://localhost:8080/web/user/list
     * @param request
     * @param response
     */
    private List list(HttpServletRequest request ,HttpServletResponse response) throws IOException, NoSuchFieldException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
        return userService.list(request,response);
    }


    private PageInfo<UmsUser> page(HttpServletRequest request , HttpServletResponse response) throws IOException, NoSuchFieldException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
        return userService.page(request,response);
    }

    /**
     * http://localhost:8080/web/user/save
     * @param request
     * @param response
     */
    public boolean save(HttpServletRequest request ,HttpServletResponse response) throws IOException {
        System.out.println("UserController.save");
        return userService.save(request,response);
    }


    /**
     * http://localhost:8080/web/user/delete
     * @param request
     * @param response
     * @throws IOException
     */
    public boolean delete(HttpServletRequest request ,HttpServletResponse response) throws IOException {
       return  userService.delete(request,response);
    }






}
